package com.atguigu.gulimall.member.web;

import com.alibaba.fastjson.TypeReference;
import com.atguigu.common.utils.Constant;
import com.atguigu.common.utils.PageUtils;
import com.atguigu.common.utils.R;
import com.atguigu.gulimall.member.feign.OrderFeignClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.HashMap;
import java.util.Map;

@Controller
public class MemberWebController {
    @Autowired
    OrderFeignClient orderFeignClient;

    @GetMapping("/memberOrder.html")
    public String orderListPage(@RequestParam(value = "pageNum",defaultValue = "1") String pageNum, Model model){
        //查询当前登录用户的订单列表数据
        Map<String, Object> params = new HashMap<>();
        params.put(Constant.PAGE,pageNum);
        R r = orderFeignClient.listWithItem(params);
        if(r.getCode()==0){
            model.addAttribute("orders",r);
        }
        return "orderList";
    }

}
